<?php

namespace app\middleware;

use app\common\ApiStatus;
use Webman\MiddlewareInterface;
use Webman\Http\Response;
use Webman\Http\Request;

class CheckIndex implements MiddlewareInterface
{
    public function process(Request $request, callable $next): Response
    {
        if ($request->host(true) != WWW_SITE) return json(['code' => ApiStatus::API_ERROR->value, 'msg' => 'RequestID:' . md5(uniqid(mt_rand(), true))]);
        return $next($request);
    }
}